<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const obj = {
        [Symbol.toPrimitive]: function (hint) {
          switch (hint) {
            case "string":
              return "hello";
            case "number":
              return 100;
            default:
              return 200;
          }
        },
      };
      obj[Symbol.toPrimitive](123);
      console.log("Number(obj)", Number(obj));
      console.log("String(obj)", String(obj));
      console.log("obj + 100", obj + 100);
      console.log("+obj", +obj);
    </script>
  </body>
</html>
